﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.ServiceLocation;

namespace NetFrameworkExtensions.Enterprise.EL5
{
  internal class ServiceLocatorToManagerAdapter :
    ServiceManagerBase
  {
    IServiceLocator serviceLocator;

    public ServiceLocatorToManagerAdapter(IServiceLocator serviceLocator)
    {
      if (serviceLocator == null)
        throw new ArgumentException("serviceLocator");
      this.serviceLocator = serviceLocator;
    }

    protected override IEnumerable<object> DoGetAllInstances(Type serviceType)
    {
      return serviceLocator.GetAllInstances(serviceType);
    }

    protected override object DoGetInstance(Type serviceType, string key)
    {
      return serviceLocator.GetInstance(serviceType, key);
    }
  }
}
